package com.cib.yym.homepage.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.cib.yym.homepage.service.ReadItLaterService;
import com.cib.yym.homepage.service.impl.ReadItLaterServiceImpl;

@Controller
@RequestMapping(value="/account")
public class AccountController {

	public final static String VIEW_SIGNIN_SUCCESS = "signinSuccess";
	public final static String VIEW_SIGNIN_FAIL = "signinFail";
	public final static String VIEW_DASHBOARD = "/my/dashboard";
	
	@RequestMapping(value="/authenticate",method=RequestMethod.POST)
	public String authenticate(@RequestParam String name,@RequestParam String password,@RequestParam String signInType)
	{
		if(signInType != null)
		{
			if(signInType.equals("readitlater"))
			{
				ReadItLaterService rService = new ReadItLaterServiceImpl();
				if(rService.authenticate(name, password))
				{
					return VIEW_SIGNIN_SUCCESS;
				}
			}
		}
		return VIEW_SIGNIN_FAIL;
		
	}
	
	@RequestMapping(value="/dashboard")
	public String dashboard()
	{
		return "/my/dashboard";
	}
	
}
